package com.iqianye.lacus17c_provider.controller;

import com.alibaba.nacos.client.utils.IPUtil;
import org.apache.catalina.util.RequestUtil;
import org.apache.tomcat.util.net.IPv6Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author mageric
 * @version 1.0.0
 * @date 2022/4/25 10:14
 */
@RestController
public class NacosProviderController {
    @Value("${server.port}")
    private String port;

    @Autowired
    private ConfigurableApplicationContext context;

    @GetMapping("/test/{message}")
    public String test(@PathVariable String message) throws UnknownHostException {
        return "Hello Nacos Discovery "+message+" ,i am from host+"+ InetAddress.getLocalHost().getHostAddress() +"+port "+port;
    }

    @GetMapping("/hi")
    public String sayHi(){
        return "Hello " + context.getEnvironment().getProperty("user.name");
    }
}
